package com.easy.cloud.web.module.certification.biz.repository;

import com.easy.cloud.web.module.certification.biz.domain.DisabilityLevelDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * DisablityLevel持久化
 *
 * @author Fast Java
 * @date 2024-04-02 20:43:33
 */
@Repository
public interface DisabilityLevelRepository extends JpaRepository<DisabilityLevelDO, String> {


    /**
     * 统计当前伤残等级下是否存在子伤残等级
     *
     * @param parentId 父级伤残等级
     * @return
     */
    long countByParentId(String parentId);

    /**
     * 判断是否已存在相同的数据
     *
     * @param parentId 父级ID
     * @param name     伤残等级名称
     * @return
     */
    Optional<DisabilityLevelDO> findByParentIdAndName(String parentId, String name);
}